#ifndef DRAWLABEL_H
#define DRAWLABEL_H

#include <QLabel>
#include <QWidget>
#include <QLabel>
#include <QPixmap>
#include <QPainter>
#include <QRegion>
#include <QStack>
#include <QRect>
#include <QVector>
#include <QPaintEvent>
#include <QPainterPath>
#include <QColor>
#include <QTextEdit>

#include "ScreenShotWidget_global.h"
#include "TextAnnotation.h"
class SCREENSHOTWIDGET_EXPORT DrawLabel : public QLabel
{
public:

    enum class DrawType{
        None,Rect,Ellipse,Arrow,CasualDraw,Text,
    };
    DrawLabel(QWidget *parent,QRect rect);

public:
    virtual void mouseMoveEvent(QMouseEvent *ev) override;
    virtual void mousePressEvent(QMouseEvent *ev) override;
    virtual void mouseReleaseEvent(QMouseEvent *ev) override;
    virtual void paintEvent(QPaintEvent *) override;

public:
    ///@brief 画笔属性改变
    void ChangePen(QPen &pen);

    ///@brief 绘制矩形
    void DrawRect();

    ///@brief 绘制原型
    void DrawEllipse();

    ///@brief 绘制箭头
    void DrawArrow(QPainter& painter);

    ///@brief 随意绘制
    void DrawCasual();

    ///@brief 绘制文本
    void DrawText();

    ///@brief 绘制文本的第二个函数
    void AddText();

    ///@brief 撤销绘制
    void ComeBack();

    ///@brief 退出文本编辑状态前将文本编辑器中内容绘制在屏幕上的函数
    void DrawTextFlush();

    ///@brief 获取画板上的pixmap
    QPixmap GetCanva();

public:
    ///@brief 每次绘制的画布
    QPixmap m_canvas;

    ///@brief 记录每次绘制好的画布用于回撤
    QStack<QPixmap> m_canvasStack;

    ///@brief label的绘制区域
    QPoint m_startPos,m_endpos;

    QRect m_region;

    ///@brief 自由绘制路线
    QPainterPath m_casualPath;

    ///@brief 画笔颜色
    QPen m_curPen;

    ///@brief 当前绘制的类型
    DrawType m_curDrawType;

    ///@brief 一组随意绘制获得的点的集合
    QVector<QPoint> m_cursualPoints;

    ///@brief 文本输入框
    QTextEdit *m_textEdit;
    TextAnnotation *m_textAnnotation;




};

#endif // DRAWLABEL_H
